package com.qf.controller;

import com.qf.service.UserService;
import com.qf.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author:zhangyang
 * @Date: 16:21
 * @Version 1.0
 */
@WebServlet("/delUserServlet")
public class DeleteUserServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //接收参数
        String id = request.getParameter("id") ;

        //调用service
        UserService userService = new UserServiceImpl() ;
        userService.delUserById(id) ;

        //重定向到findUserList  ---完成页面跳转
        response.sendRedirect(request.getContextPath()+"/findUserList");

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
